package HashBuck;

import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 故我
 * Date: 2024-02-07
 * Time: 21:22
 */

class Person {

}

public class TestMain {
    public static void main(String[] args) {
        HashKV<String,Integer> hashKV = new HashKV<>();
        hashKV.put("hello",10);
        hashKV.put("nhao",20);
        System.out.println(hashKV.getValue("hello"));
    }
    public static void main2(String[] args) {
        // 统计每个数字出现的次数
        int[] array = {1, 2, 2, 3, 3, 4, 5, 5, 5, 5, 3, 3, 5, 6, 7, 8, 9, 111};
        Map<Integer, Integer> map = new HashMap<>();
        for (int x : array) {
            if (map.get(x) == null) {
                // 此时map中不含 x
                map.put(x, 1);
            } else {
                int val = map.get(x);
                map.put(x, val + 1);
            }
        }

        for (Map.Entry<Integer, Integer> it : map.entrySet()) {
            System.out.println("key: " + it.getKey() + " value: " + it.getValue());
        }
    }

    public static void main1(String[] args) {
        HashDemo hashDemo = new HashDemo();
        hashDemo.put(1, 10);
        hashDemo.put(2, 60);
        hashDemo.put(3, 40);
        hashDemo.put(4, 20);
        hashDemo.put(5, 30);
        System.out.println(hashDemo.get(3));
    }
}
